package com.ljx.date.date01;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @author LJX
 * @Description: TODO
 * @Date: 2022/11/7 14:14
 * @Version 1.0
 */
public class LocalDateAndLocalTimeAndLocalDateTime {
	public static void main(String[] args) {
		// 创建一个指定日期时间的类
		LocalDateTime localDateTime = LocalDateTime.of(2021, 12, 20,12,12,12);
		System.out.println(localDateTime);
		// 创建当前日期时间对象
		LocalDateTime now = LocalDateTime.now();
		System.out.println(now);
		// 创建只有日期类型的指定时间类和当前时间类
		LocalDate of = LocalDate.of(2022, 12, 10);
		LocalDate now1 = LocalDate.now();
		System.out.println(of+"~~~~~~~~~~~~~~~~~~~"+now1);
		// 日期类中常用的方法
		System.out.println(now1.getDayOfMonth());
		System.out.println(now1.getDayOfYear());
		System.out.println(now1.getDayOfWeek().getValue());
		System.out.println(now1.getYear());
		System.out.println(now1.getMonth().getValue());



		// 创建只有时间的指定时间日期类和当前时间类
		LocalTime time = LocalTime.of(12, 12, 23);
		LocalTime time1 = LocalTime.now();
		System.out.println(time+"~~~~~~~~~~~"+time1);
		// 时间类中常用的方法
		System.out.println(time1.getHour());
		System.out.println(time1.getMinute());
		System.out.println(time1.getSecond());
		System.out.println(time1.getNano());
		// 时间加上两个小时
		System.out.println(time1.plusHours(2));
		// 时间减去20分钟
		System.out.println(time1.minusMinutes(20));



	}
}
